/* GUI CONVERTED from rwrorp02.p (converter v1.76) Mon Sep 17 22:18:45 2001 */
/* rwrorp02.p - ITEM ROUTING COST REPORT                                */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.7.1.5 $                                                   */
/*V8:ConvertMode=FullGUIReport                                          */
/* REVISION: 1.0      LAST MODIFIED: 01/12/87   BY: EMB                 */
/* REVISION: 1.0      LAST MODIFIED: 08/29/86   BY: EMB *12*            */
/* REVISION: 1.0      LAST MODIFIED: 09/02/87   BY: WUG *A94*           */
/* REVISION: 4.0      LAST MODIFIED: 03/18/88   BY: EMB *A171*          */
/* REVISION: 4.0      LAST MODIFIED: 02/24/88   BY: WUG *A175*          */
/* REVISION: 4.0      LAST MODIFIED: 01/10/89   BY: flm *A580*          */
/* REVISION: 6.0      LAST MODIFIED: 10/10/90   BY: emb *D086*          */
/* REVISION: 6.0      LAST MODIFIED: 11/05/90   BY: emb *D175*          */
/* REVISION: 6.0      LAST MODIFIED: 03/29/91   BY: emb *D465*          */
/* REVISION: 6.0      LAST MODIFIED: 06/26/91   BY: emb *D736*          */
/* REVISION: 6.0      LAST MODIFIED: 08/21/91   BY: bjb *D811*          */
/* REVISION: 7.0      LAST MODIFIED: 07/16/92   BY: pma *F775*          */
/* REVISION: 7.3      LAST MODIFIED: 05/17/93   BY: pma *GB01*          */
/* REVISION: 7.3      LAST MODIFIED: 12/29/93   BY: ais *FL07*          */
/* REVISION: 7.3      LAST MODIFIED: 11/20/95   BY: bcm *G1DD*          */
/* REVISION: 8.6      LAST MODIFIED: 10/15/97   BY: bvm *K0ZZ*          */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane    */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb          */
/* Old ECO marker removed, but no ECO header exists *F0PN*              */
/* Revision: 1.7.1.4     BY: Hualin Zhong   DATE: 05/08/01 ECO: *N0YC*  */
/* $Revision: 1.7.1.5 $    BY: Manjusha Inglay   DATE: 08/28/01  ECO: *P01R* */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/* DISPLAY TITLE */

/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rwrorp02_p_1 "Lbr Burden!Mch Burden"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp02_p_2 "As of Date"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp02_p_3 "Lbr Bdn Rate!Mch Bdn Rate"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp02_p_4 "Labor Cost"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp02_p_5 "Lbr Bdn %!Mch per Op"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp02_p_8 "Setup Rate!Labor Rate"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp02_p_9 "Work Ctr!Machine"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp02_p_10 "Setup Time!Order Qty"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp02_p_14 "Total!Burden"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp02_p_15 "Unit Setup!Unit Run"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable part like pt_part.
define variable part1 like pt_part.
define variable wkctr like ro_wkctr.
define variable eff_date like op_date initial today
   label {&rwrorp02_p_2}.
define variable unit_setup like ro_setup.
define variable unit_labor like ro_run.
define variable labor_cost like sct_lbr_tl
   format ">,>>>,>>9.99<<<<<<<<".
define variable labor_burden like sct_bdn_tl
   format ">,>>>,>>9.99<<<<<<<<".
define variable mch_bdn_cost like sct_bdn_tl
   format ">,>>>,>>9.99<<<<<<<<".
define variable total_burden like sct_bdn_tl
   format ">,>>>,>>9.99<<<<<<<<".
define variable total_labor_cost like sct_lbr_tl
   format ">,>>>,>>9.99<<<<<<<<".
define variable total_total_burden like sct_bdn_tl
   format ">,>>>,>>9.99<<<<<<<".
define variable total_ro_sub_cost like sct_sub_tl
   format ">,>>>,>>9.99<<<<<<<<".

define variable i as integer.
define variable ord_qty like pt_ord_qty.
define variable part_yield like pt_yield_pct.
define variable sub_cost as decimal.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
part           colon 15
   part1          label {t001.i}
   eff_date colon 15
   wkctr          colon 15 skip
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

{wbrp01.i}


/*GUI*/ {mfguirpa.i true "printer" 132 " " " " " "  }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:


   if part1 = hi_char then part1 = "".

   if c-application-mode <> 'web' then
   
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


   {wbrp06.i &command = update &fields = "  part part1 eff_date wkctr" &frm = "a"}

   if (c-application-mode <> 'web') or
      (c-application-mode = 'web' and
      (c-web-request begins 'data')) then do:

      bcdparm = "".
      {mfquoter.i part     }
      {mfquoter.i part1    }
      {mfquoter.i eff_date }
      {mfquoter.i wkctr    }

      if part1 = "" then part1 = hi_char.

   end.

   /* OUTPUT DESTINATION SELECTION */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i "printer" 132 " " " " " " " " }
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:



   {mfphead.i}

   for each pt_mstr no-lock where pt_part >= part and pt_part <= part1
         and can-find (first ro_det where
         ro_routing = if pt_routing > "" then pt_routing else pt_part),
         each ro_det no-lock where
         ro_routing = (if pt_routing > "" then pt_routing else pt_part)
         and (eff_date = ? or ((ro_start = ? or ro_start <= eff_date)
         and (ro_end = ? or ro_end >= eff_date)))
         and (ro_wkctr = wkctr or wkctr = "")
         break by pt_part by ro_routing by ro_op with frame b:

      FORM /*GUI*/ 
         space(9)
         ro_wkctr     column-label {&rwrorp02_p_9}
         ro_setup     column-label {&rwrorp02_p_10}
         unit_setup   column-label {&rwrorp02_p_15}
         unit_labor   column-label {&rwrorp02_p_8}
         labor_cost   column-label {&rwrorp02_p_4}
         wc_bdn_pct   column-label {&rwrorp02_p_5}
         wc_bdn_rate  column-label {&rwrorp02_p_3}
         labor_burden column-label {&rwrorp02_p_1}
         total_burden column-label {&rwrorp02_p_14}
         ro_sub_cost format ">,>>>,>>9.99<<<<<<<<"
      with STREAM-IO /*GUI*/  frame b width 132 no-attr-space.

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame b:handle).

      if first-of(ro_routing) then do:
         if page-size - line-counter < 4 then page.
         assign
            total_labor_cost = 0
            total_total_burden = 0
            total_ro_sub_cost = 0
            part_yield = 100.
         display with frame b STREAM-IO /*GUI*/ .
         put {gplblfmt.i &FUNC=getTermLabel(""ITEM"",6) &CONCAT="':'"}
            space(1) pt_part
            pt_desc1 + " " + pt_desc2 format "x(49)".
         if pt_routing > "" then
         put space(6)
            {gplblfmt.i &FUNC=getTermLabel(""ROUTING"",9) &CONCAT="':'"}
            space(1) pt_routing.
      end.

      find wc_mstr where wc_wkctr = ro_wkctr
         and wc_mch = ro_mch
         no-lock no-error.

      ord_qty = 1.
      if pt_ord_qty <> 0 then ord_qty = pt_ord_qty.
      assign
         unit_setup = ro_setup / ord_qty
         unit_labor = unit_setup + ro_run
         sub_cost   = (ro_sub_cost
            * part_yield * .01 * ro_yield_pct * .01)
         labor_cost = (((ro_setup / ord_qty) * wc_setup_rte)
            + (ro_run * wc_lbr_rate))
            * part_yield * .01.

      /*! CALCULATE TOTAL OPERATION BURDEN USING THE STANDARD     *
      *  EQUATION.                                               */
      {gprun.i ""rwbdncal.p""
         "( input 'TOTAL'              /* BURDEN COST TYPE */,
            input no                  /* ACCUMULATE TOTAL? */,
            input (wc_bdn_pc * 0.01)     /* BURDEN PERCENT */,
            input wc_bdn_rate               /* BURDEN RATE */,
            input wc_lbr_rate                /* LABOR RATE */,
            input wc_mch_bdn        /* MACHINE BURDEN RATE */,
            input ro_mch_op               /* MACHINES USED */,
            input ord_qty                /* ORDER QUANTITY */,
            input ro_run                  /* UNIT RUN TIME */,
            input wc_setup_rte               /* SETUP RATE */,
            input ro_setup                   /* SETUP TIME */,
            input (part_yield * 0.01)     /* YIELD PERCENT */,
            input-output total_burden       /* BURDEN COST */
                )"
         }

      /*! CALCULATE OPERATION LABOR BURDEN USING THE STANDARD     *
      *  EQUATION.                                               */
      {gprun.i ""rwbdncal.p""
         "( input 'LABOR'              /* BURDEN COST TYPE */,
            input no                  /* ACCUMULATE TOTAL? */,
            input (wc_bdn_pc * 0.01)     /* BURDEN PERCENT */,
            input wc_bdn_rate               /* BURDEN RATE */,
            input wc_lbr_rate                /* LABOR RATE */,
            input 0                 /* MACHINE BURDEN RATE */,
            input 0                       /* MACHINES USED */,
            input ord_qty                /* ORDER QUANTITY */,
            input ro_run                  /* UNIT RUN TIME */,
            input wc_setup_rte               /* SETUP RATE */,
            input ro_setup                   /* SETUP TIME */,
            input (part_yield * 0.01)     /* YIELD PERCENT */,
            input-output labor_burden /* LABOR BURDEN COST */
                )"
         }

      assign
         mch_bdn_cost = max(total_burden - labor_burden, 0)
         part_yield = part_yield * .01 * ro_yield_pct.

      if page-size - line-counter < 3 then do:
         page.
         down 1 with frame b.
      end.
      put skip space(2)
         {gplblfmt.i &FUNC=getTermLabel(""OPERATION"",3) &CONCAT="':'"}
         space(1) string(ro_op) space(1) ro_desc.
      if ro_std_op > "" then
         put space(1)
            {gplblfmt.i &FUNC=getTermLabel(""STANDARD_OPERATION"",8)
                        &CONCAT="':'"}
            space(1) ro_std_op.

      display
         ro_wkctr
         wc_bdn_rate wc_bdn_pct
         ro_setup unit_setup
         wc_setup_rte format ">>>,>>9.99" @ unit_labor
         labor_burden WITH STREAM-IO /*GUI*/ .

      down 1.
      display
         ro_mch @ ro_wkctr
         pt_ord_qty format ">,>>>,>>9.9" @ ro_setup
         ro_run @ unit_setup
         wc_lbr_rate format ">>>,>>9.99" @ unit_labor
         mch_bdn_cost @ labor_burden
         ro_mch_op format ">>>>>" @ wc_bdn_pct
         wc_mch_bdn  @ wc_bdn_rate
         labor_cost total_burden
         sub_cost @
         ro_sub_cost WITH STREAM-IO /*GUI*/ .

      assign
         total_labor_cost = total_labor_cost + labor_cost
         total_total_burden = total_total_burden + total_burden
         total_ro_sub_cost = total_ro_sub_cost + sub_cost.

      if last-of(ro_routing) then do:

         underline labor_cost total_burden ro_sub_cost.
         display
            total_labor_cost @ labor_cost
            total_total_burden @ total_burden
            total_ro_sub_cost @ ro_sub_cost WITH STREAM-IO /*GUI*/ .

         if part_yield <> 0 and part_yield <> 100 then do:
            assign
               total_labor_cost = total_labor_cost / (part_yield * .01)
               total_total_burden = total_total_burden / (part_yield * .01)
               total_ro_sub_cost = total_ro_sub_cost / (part_yield * .01).
            down 1.
            display
               getTermLabel("YIELD",7) + " :" @ ro_setup
               string(part_yield,">>9.99%") @ unit_setup
               total_labor_cost @ labor_cost
               total_total_burden @ total_burden
               total_ro_sub_cost @ ro_sub_cost WITH STREAM-IO /*GUI*/ .
         end.

      end.

      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

   end.

   /* REPORT TRAILER  */
   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end.

{wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" part part1 eff_date wkctr "} /*Drive the Report*/
